<?php
$htmlFunc = create_function('$resourceIds, $r, $mca, $p = null', '
$class = $p ? "class=\"child-of-node-{$p}\"":"";
$checkbox = "";
if ($resourceIds !== null) {
    $checked = in_array($r->getResourceId(), $resourceIds) ? "checked" : "";
    $checkbox = "<input class=\"expander\" parentbox=\"$p\" type=\"checkbox\" name=\"resource_id[]\" value=\"{$r->getResourceId()}\" $checked>";
}
$html = <<<EOT
     <tr id="node-{$r->getResourceId()}" $class>
        <td>{$checkbox}{$mca}</td>
        <td name="employee">{$r->getEmployee()}</td>
        <td name="name">{$r->getName()}</td>
        <td>{$r->getAtime()}</td>
        <td name="param">{$r->getParam()}</td>
        <td class="">{$r->getResourceId()}</td>
        <td align="center">
          <button onclick="ResourceList.data.edit({$r->getResourceId()}, this);" title="编辑" class="ui-icon-pencil"></button>
        </td>
    </tr>
EOT;
return $html;
');
?>
<form id="dialog" class="hide">
    <table class="none">
      <tr>
        <td align="right">添加者: </td>
        <td><input type="text" name="employee" /></td>
      </tr>
      <tr>
        <td align="right">资源名称:</td>
        <td><input type="text" name="name" /></td>
      </tr>
      <tr>
        <td align="right">参数:</td>
        <td><input type="text" name="param" /></td>
      </tr>
    </table>
    <button class="hide"></button>
</form>

<div id="content-bar">
  <button id="refresh" class="ui-icon-refresh">更新资源</button>

  <button onclick="ResourceList.expandAll()" class="ui-icon-circlesmall-plus">展开全部</button>

  <button onclick="ResourceList.drawAll()" class="ui-icon-circlesmall-minus">收缩全部</button>
<p />
提示:按住CTRL+左键点击, 选中其所有子项.
</div>
<br>
<style>
.draggTable tr > td:FIRST-CHILD {
    padding-left:1.5em;
}
</style>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tab-1 draggTable" id="list">
    <tr>
        <th width="330">模块</th>
        <th width="80">添加者</th>
        <th>资源名称</th>
        <th width="130">添加时间</th>
        <th>参数</th>
        <th class="">ID</th>
        <th>操作</th>
    </tr>
<?php
    foreach ($this->data as $modules){
        echo $htmlFunc($this->resourceIds, $modules['data'], $modules['data']->getModule());
        foreach ($modules['ctrls'] as $ctrl){
            echo $htmlFunc(
                $this->resourceIds,
                $ctrl['data'],
                "{$modules['data']->getModule()}.{$ctrl['data']->getController()}",
                $modules['data']->getResourceId());
            foreach ($ctrl['actions'] as $action){
                echo $htmlFunc(
                    $this->resourceIds,
                    $action,
                    "{$modules['data']->getModule()}.{$ctrl['data']->getController()}.{$action->getAction()}",
                    $ctrl['data']->getResourceId());
            }
        }
    }
?>
</table>

<div id="content-bar">
  角色分配权限:<select onchange="location.href='/system/resource/list/role_id/'+this.value">
  <option value="">--请选择--</option>
  <?php foreach ($this->roles as $role):?>
  <option value="<?=$role->getRoleId()?>" <?=$this->roleId == $role->getRoleId()?'selected':''?>><?=$role->getTitle()?></option>
  <?php endforeach;?>
  </select>
  <button onclick="ResourceList.assign(this)" class="ui-icon-check">提 交</button>
</div>
